/**
 * AgeSorterer.java
 * ************************** 
 * @date Apr 27, 2011
 * @author Michele Tamburini
 * 
 * **************************
 */
package gossipServices.basic.nodeDescriptors.comparators;

import gossipServices.basic.nodeDescriptors.NodeDescriptor;
import gossipServices.basic.nodeDescriptors.PssNodeDescriptor;

/**
 * Description: 
 * It takes two PssNodeDescriptor(s) in input 
 * (or any NodeDescritor able to manage the age).
 * Returns their age comparison: 
 * 		-1 if o1.getAge() < o2.getAge();
 * 		 0 if o1.getAge() == o2.getAge();
 * 		 1 if o1.getAge() > o2.getAge();  
 *
 */
public class AgeSorterer implements NodeDescriptorComparator {

	/**
	 * 
	 */
	public AgeSorterer() { }

	@Override
	public int compare(NodeDescriptor o1, NodeDescriptor o2) {
		PssNodeDescriptor pssO1 = (PssNodeDescriptor) o1;
		PssNodeDescriptor pssO2 = (PssNodeDescriptor) o2;
		return pssO1.getAge().compareTo(pssO2.getAge());
	}

}
